package org.electrical.controller.functionality;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.electrical.dao.EleStockDao;
import org.electrical.pojo.EleStock;
import org.electrical.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/stock")
@CrossOrigin(value = "*")
public class EleStockController {

    @Autowired
    private EleStockDao eleStockDao;

    @RequestMapping("list")
    @ResponseBody
    public ResponseResult<List<EleStock>> list(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit, String goodsName, String storeName) {

        //Page<EleStock> pager = PageHelper.startPage(page, limit);
        //pager.getTotal(),
        List<EleStock> list = eleStockDao.getCondition(goodsName, storeName);
        return new ResponseResult(list);

    }

}
